package com.sugon.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.DevAmRulesOptionDao;
import com.sugon.entity.DevAmRulesOptionEntity;
import com.sugon.service.DevAmRulesOptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 维护规程选项关联表Service实现类
 *
 * @author sugon
 * @date 2019-07-18 15:31:48
 */
@Service("devAmRulesOptionService")
public class DevAmRulesOptionServiceImpl implements DevAmRulesOptionService {

    @Autowired
    private DevAmRulesOptionDao devAmRulesOptionDao;

    /**
     * queryObject
     *
     * @param id 主键
     * @return
     */
    @Override
    public DevAmRulesOptionEntity queryObject(String id) {
        return devAmRulesOptionDao.queryObject(id);
    }

    /**
     * queryList
     *
     * @param map 参数
     * @return
     */
    @Override
    public List<DevAmRulesOptionEntity> queryList(Map<String, Object> map) {
        return devAmRulesOptionDao.queryList(map);
    }

    /**
     * queryTotal
     *
     * @param map 参数
     * @return
     */
    @Override
    public int queryTotal(Map<String, Object> map) {
        return devAmRulesOptionDao.queryTotal(map);
    }

    /**
     * save
     *
     * @param devPlanOption 实体
     * @return
     */
    @Override
    public int save(DevAmRulesOptionEntity devPlanOption) {
        devPlanOption.setId(RandomUtil.randomString(32));
        return devAmRulesOptionDao.save(devPlanOption);
    }

    /**
     * update
     *
     * @param devPlanOption 实体
     * @return
     */
    @Override
    public int update(DevAmRulesOptionEntity devPlanOption) {
        return devAmRulesOptionDao.update(devPlanOption);
    }

    /**
     * delete
     *
     * @param id
     * @return
     */
    @Override
    public int delete(String id) {


        return devAmRulesOptionDao.delete(id);
    }

    /**
     * deleteBatch
     *
     * @param ids
     * @return
     */
    @Override
    public int deleteBatch(String[] ids) {
        return devAmRulesOptionDao.deleteBatch(ids);
    }

    /**
     * isHave
     *
     * @param planId
     * @param opId
     * @return
     */
    @Override
    public int isHave(String planId, String opId) {
        Map<String, Object> param = new HashMap<>(2);
        param.put("planId", planId);
        param.put("opId", opId);
        return devAmRulesOptionDao.queryTotal(param);
    }

    /**
     * getByPlanId
     *
     * @param planId 规程ID
     * @return
     */
    @Override
    public List<DevAmRulesOptionEntity> getByPlanId(String planId) {
        Map<String, Object> param = new HashMap<>(2);
        param.put("planId", planId);
        return devAmRulesOptionDao.queryList(param);
    }

}
